var express = require('express');
var router = require('./router.js');
var bodyParser = require('body-parser');
var session = require('express-session');
var cookieParser = require('cookie-parser');

var app = express();
app.use(express.static('src'));
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:false}));
app.use(session({
    secret :  '12345', // 对session id 相关的cookie 进行签名
    name : 'testapp', //cookie名字
    resave : true,//即使 session 没有被修改，也保存 session 值，默认为 true。
    rolling : true,//每个请求都重新设置一个 cookie
    saveUninitialized: false, // 是否保存未初始化的会话
    cookie : {
        maxAge : 60000, // 设置 cookie 的有效时间，单位毫秒
    }
}));

app.get('/',router.status);//主页
app.post('/login',router.login);//登录ajax

app.get('/frozen',router.frozen);//冻结

app.get('/loading',router.loading);

app.get('/business',router.business);//业务
app.get('/logout',router.logout);//登出

app.get('/withdraw',router.withdraw);//取款
app.post('/business/withdraw',router.withdraw_2);//取款数据
app.get('/successfulWithdraw',router.successfulWithdraw);//取款成功

app.get('/deposit',router.deposit)//存款
app.post('/business/deposit',router.deposit_2);//存款数据
app.get('/depositSuccess',router.depositSuccess);//存款成功
app.post('/business/deposit/depositsuccess',router.depositSuccess_2);//存款成功数据

app.get('/balance',router.balance);//查额
app.get('/business/query/accountBalance',router.balance_2);//查额初始化

app.get('/account',router.account); //转账
app.post('/business/transfer/checkToAccount',router.account_2);//转账账户核查
app.get('/transfer',router.transfer);//转账金额
app.post('/money',router.money);//保存转账金额
app.get('/confirm',router.confirm); //转账信息确认页面
app.post('/confirm2',router.confirm2);//转账信息确认初始化
app.get('/password',router.password);//转账密码页面
app.post('/business/transfer/checkpwd',router.password_2);//密码验证
app.get('/successfultransfer',router.successfultransfer)//密码成功
app.post('/successfultransfer_2',router.successfultransfer_2);//转账成功

app.get('/detailed',router.detailed);//明细查询
app.get('/business/query/statement',router.detailed_2);// 明细查询数据

app.get('/changePassword',router.changePassword);//改密
app.post('/user/changepwd',router.changepwd);//改密ajax
app.get('/successpass',router.successpass)//改密成功

app.get('/business/query/advice',router.advice)//打印凭条
app.listen(80);

